﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:Controls="clr-namespace:Columbus.Controls"
    xmlns:Converters="clr-namespace:Columbus.Converters">

    <Style TargetType="Controls:Frame">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Controls:Frame">
                    <Grid>
                        <FrameworkElement.Resources>
                            <Converters:BooleanToVisibilityConverter x:Key="boolToVisibilityConverter" />
                            <Converters:InverseBooleanConverter x:Key="inverseBoolConverter" />
                            <Converters:BooleanToOpacityConverter x:Key="boolToOpacityConverter" />
                        </FrameworkElement.Resources>
                        
                        <StackPanel
                            HorizontalAlignment="Center"
                            VerticalAlignment="Center">
                            <ContentPresenter 
                                x:Name="PART_ProgressIndicator"
                                HorizontalAlignment="Center"
                                VerticalAlignment="Center"
                                Content="{TemplateBinding ProgressIndicator}"
                                Visibility="{Binding IsNavigationInProgress, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource boolToVisibilityConverter}, ConverterParameter=FalseMeansCollapsed}"/>
                            <Button 
                                x:Name="PART_CancelButton"
                                Content="{TemplateBinding CancelButtonContent}"
                                Visibility="{Binding IsAllowedToCancel, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource boolToVisibilityConverter}, ConverterParameter=FalseMeansCollapsed}">
                            </Button>
                        </StackPanel>
                        
                        <ContentControl
                            IsEnabled="{TemplateBinding IsContentEnabled}"
                            Opacity="{Binding IsNavigationInProgress, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource boolToOpacityConverter}}"
                            HorizontalContentAlignment="Stretch"
                            VerticalContentAlignment="Stretch">
                            <ContentPresenter x:Name="PART_MainContent"
                                              Content="{TemplateBinding Content}" />
                        </ContentControl>
                        
                        <ContentControl
                            HorizontalAlignment="Center"
                            VerticalAlignment="Center">
                            <ContentPresenter 
                                x:Name="PART_DialogContent"
                                Content="{TemplateBinding Dialog}" />
                        </ContentControl>

                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>